package com.xidian.zhiancloud.controller.exam;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.aliyuncs.exceptions.ClientException;
import com.github.pagehelper.Page;
import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.model.exam.PlanUserMark;
import com.xidian.zhiancloud.model.exam.TrainPlan;
import com.xidian.zhiancloud.service.exam.ITrainPlanService;
import com.xidian.zhiancloud.util.tools.AliyunSmsUtils;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;


/**
 * 短信发送Controller
 * 
 * @author zhouweitao
 * @date 2021-03-16
 */
@RestController
@Api(tags="发送短信")
@RequestMapping("/msg")
public class MsgController 
{
	
	  /**
     *发送短信 telephone:手机号码 ， type: 1表示重置密码， 0表示登录验证 
     */
	 @GetMapping("/sendMsg")
    public ResultDTO sendMsg(@Param("telephone")String telephone,@Param("type")String type) throws ClientException {
    	String resutl = AliyunSmsUtils.sendCode(telephone,type);
    	System.out.println(resutl+"-----------");
        return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
        
    } 
	 /**
	  * 
	  * @param telephone :手机号码
	  * @param name  姓名
	  * @param type 1表示排查计划，0隐患排查
	  * @return
	  * @throws ClientException
	  */
	@GetMapping("/sendWarmMsg")
    public ResultDTO sendWarnMsg(@Param("telephone")String telephone,@Param("name")String name,@Param("type")String type) throws ClientException {
    	String resutl = AliyunSmsUtils.sendWarn(telephone, name, type);
    	System.out.println(resutl+"-----------");
        return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
        
    } 
	  /**
	   * 获取验证码 
	   * @param telephone
	   * @return
	   */
    @GetMapping("/getCode")
    public ResultDTO getMsg(@Param("telephone")String telephone) {
    	String code = AliyunSmsUtils.checkCode(telephone);
    	System.out.println(code+"--------");
        return ResultDTO.successOf(code,GeneralResponseEnums.SUCCESS);
    } 
	    
}
